<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head th:replace="~{common::header('未通过审批采购计划一览表')}"></head>
<body>
<div class="container-fluid">
    <div class="row clearfix">
        <div class="col-md-12 column" style="text-align: center">
            <h3>
                未通过审批采购计划一览表
            </h3>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <hr>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="col-sm-3 col-sm-0 col-md-4 column form-inline">

            </div>


            <div class="col-sm-6 col-md-4 column form-inline" style="text-align: center">
                <label for="a1">计划状态:</label>
                <select class="form-control" id="a1">
                    <option>全部</option>
                    <option value="S002-01">驳回</option>
                    <option value="S002-02">废弃</option>
                </select>
                <button type="button" class="btn btn-primary" onclick="btn1()" style="margin-left: 10px">搜索</button>
            </div>

            <div class="col-sm-3 col-md-4 column form-inline">

            </div>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <hr>
        </div>
    </div>
    <div class="row clearfix" style="max-height: 50%;overflow-y: auto;overflow-x: hidden">
        <div class="row clearfix">
            <div class="col-md-12 column">
                <div class="col-md-12 column" style="overflow: hidden">
                    <table id="dg" class="easyui-datagrid"
                           data-options="
								  	pageSize:'10',
								  	pageList:[10,20,30,40],
									pagination:true,
									rownumbers:true,
									url:'/stock/selectStockByStatus2',
									method:'post',
									width:'100%'">
                        <thead>
                        <tr>
                            <th data-options="field:'ck',checkbox: true"></th>
                            <th data-options="field:'ID'" hidden>Item ID(15%)</th>
                            <th data-options="field:'STOCK_NUM',width:'15%'">Item ID(15%)</th>
                            <th data-options="field:'STOCK_NAME',width:'15%'">Product(15%)</th>
                            <th data-options="field:'STOCK_TYPE',width:'15%',formatter: function(value,row,index){
                                                                                    if(value=='C000-1'){
                                                                                        return '公开求购';
                                                                                    }else{
                                                                                        return '定向询价';
                                                                                    }}">Product(15%)</th>
                            <th data-options="field:'LEAD_AGREE',width:'15%',formatter: function(value,row,index){
                                                                                    if(value=='S002-01'){
                                                                                        return '驳回';
                                                                                    }else{
                                                                                        return '废弃';
                                                                                    }}">Product(15%)</th>
                            <th data-options="field:'LEADER',width:'15%'">Product(15%)</th>
                            <th data-options="field:'LEAD_DATE',width:'15%'">Product(15%)</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>


    <div class="row clearfix">
        <div class="col-md-12 column">
            <hr>
        </div>
    </div>

    <div class="col-md-12 column">
        <div class="col-md-12 column" style="padding-top:10px;text-align:center">
            <button type="button" onclick="btn2()"  class="btn btn-primary" >详情</button>
            <button type="button" onclick="btn3()"  class="btn btn-primary" >修改</button>
            <button type="button" onclick="btn5()"  class="btn btn-primary" >删除</button>
        </div>
    </div>

</div>


<script>

    //模糊查询
    var btn1=function (){
        var a1=$("#a1").val();
        $('#dg').datagrid({
            url:'/stock/selectStockByStatus2',
            method:'post',
            queryParams: {
                zt:a1,
            }
        });
    }

    var btn2=function (){
        var rows= $("#dg").datagrid("getSelections");
        if (rows.length!=0){
            for (var i = 0; i < rows.length; i++) {
                URL1="/stock/findbyID?ID="+rows[i].ID;
                open(URL1,"","");
            }
        }
    }

    var btn3=function (){
        var rows= $("#dg").datagrid("getSelections");
        if (rows.length!=0){
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].LEAD_AGREE=='S002-01'){
                    URL1="/stock/updatebyID?ID="+rows[i].ID;
                    open(URL1,"","");
                }
            }
        }
    }

    var btn4=function (){
        $('#dg').datagrid('reload');
    }

    var btn5=function (){
        var rows= $("#dg").datagrid("getSelections");
        if (rows.length!=0){
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].LEAD_AGREE=='S002-02'){
                    $.ajax({
                        url:'/stock/delectByid?id='+rows[i].ID,
                        method:'post',
                        success:function (data){
                            $('#dg').datagrid('reload');
                        }
                    })
                }
            }
        }
    }

</script>


</body>

</html>